const state = {
  attrList: JSON.parse(sessionStorage.getItem('attrList')) || [],
  listTotal: sessionStorage.getItem('listTotal') || 0,
  isShowBack: sessionStorage.getItem('isShowBack') || false,
  historyArr: JSON.parse(sessionStorage.getItem('historyArr')) || [],
  assetsObj: JSON.parse(sessionStorage.getItem('assetsObj')) || {},
}
const mutations = {
  // changeShowtab1(state, data) {
  //   state.showtab1 = data;
  //   sessionStorage.setItem("showtab1", data);
  // },
  changeAttrList(state, data) {
    state.attrList = data
    var e = JSON.stringify(data)
    sessionStorage.setItem('attrList', e)
  },
  changeListTotal(state, data) {
    state.listTotal = Number(data)
    sessionStorage.setItem('listTotal', Number(data))
  },
  CHANGE_SHOWBACK: (state, data) => {
    state.isShowBack = data
    sessionStorage.setItem('isShowBack', data)
  },
  changeHistory(state, data) {
    state.historyArr.push(data)
    sessionStorage.setItem('historyArr', JSON.stringify(state.historyArr))
  },
  clearHistory(state, value) {
    state.historyArr = []
    sessionStorage.setItem('historyArr', [])
  },
  changeAssetsObj(state, data) {
    state.assetsObj = data
    var e = JSON.stringify(data)
    sessionStorage.setItem('assetsObj', e)
  },
}
export default {
  namespaced: true,
  state,
  mutations,
}
